#include <stdio.h>
#include <stdlib.h>

typedef struct Node {
    int data;
    struct Node *next;
} Node;

Node* createList(int n) {
    Node *head = (Node*)malloc(sizeof(Node));
    head->next = NULL;
    Node *tail = head;
    for (int i = 0; i < n; i++) {
        int data;
        scanf("%d", &data);
        Node *newNode = (Node*)malloc(sizeof(Node));4
        newNode->data = data;
        newNode->next = NULL;
        tail->next = newNode;
        tail = newNode;
    }
    return head;
}

int deleteNode(Node *head, int i) {
    if (i <= 0) return 0;
    Node *p = head;
    int j = 0;
    while (p != NULL && j < i - 1) {
        p = p->next;
        j++;
    }
    if (p == NULL || p->next == NULL) {
        return 0;
    }
    Node *temp = p->next;
    p->next = temp->next;
    free(temp);
    return 1;
}

void printList(Node *head) {
    Node *cur = head->next;
    if (cur == NULL) {
        printf("null\n");
        return;
    }
    int first = 1;
    while (cur != NULL) {
        if (!first) {
            printf(" ");
        }
        printf("%d", cur->data);
        first = 0;
        cur = cur->next;
    }
    printf("\n");
}

void freeList(Node *head) {
    Node *p = head;
    while (p != NULL) {
        Node *temp = p;
        p = p->next;
        free(temp);
    }
}

int main() {
    int n, i;
    scanf("%d", &n);
    Node *head = createList(n);
    scanf("%d", &i);
    int success = deleteNode(head, i);
    if (success) {
        printList(head);
    } else {
        printf("error\n");
    }
    freeList(head);
    return 0;
}
